"use strict";
function _typeof(t) {
    return(_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) {
    
        return  typeof t
      
    }
        : function (t) {
            return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
           
        })(t)
}
function ownKeys(e, t) {
    var r, o = Object.keys(e);
    return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
        t && (r = r.filter(function (t) {
            return            Object.getOwnPropertyDescriptor(e, t).enumerable

        })),
        o.push.apply(o, r)), o
}
function _objectSpread(e) {
    for (var t = 1;
        t < arguments.length; t++) {
        var r = null != arguments[t] ? arguments[t] : {};
        t % 2 ? ownKeys(Object(r), !0).forEach(function (t) {
            _defineProperty(e, t, r[t])
        })
            : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r))
                : ownKeys(Object(r)).forEach(function (t) {
                    Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
                })
    }
    return e
}
function _defineProperty(t, e, r) {
    return e in t ? Object.defineProperty(t, e, {
   
        value: r,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = r, t
}
function sum() {
    for (var t = 0, e = 0; e <= arguments.length - 1; e++)t += arguments[e];
    return t
}
function randomNum(t, e) {
    return
    Math.floor(Math.random() * (Math.abs(t - e) + 1)) + Math.min(t, e)
}
function parseQueryString(t) {
    var e = {};
    return t.split("&").forEach(function (t) {
        e[t.split("=")[0]] = t.split("=")[1]
    }),
        e
}
function queryString(t) {
    var e, r = "";
    for (e in t) r += e + "=" + t[e] + "&";
    return r = r.slice(0, r.length - 1)
}
function randomColor() {
    var t = randomNum(0, 255),
        e = randomNum(0, 255),
        r = randomNum(0, 255);
    return "rgb(".concat(t, ", ").concat(e, ", ").concat(r, ")")
   
}
function diffTime(t, e) {
    t = Math.ceil(Math.abs(t - e) / 1e3);
    return {
        day: parseInt(t / 86400),
        hours: parseInt(t % 86400 / 3600),
        minutes: parseInt(t % 3600 / 60),
        seconds: t % 60
    }
}
function move(n, a, c) {
    var t, i = 0; for (t in a)
        !function (r) {
            i++,
                "opacity" === r && (a[r] = 100 * a[r]);
            var o = setInterval(function () {
                var t = "opacity" === r ? 100 * window.getComputedStyle(n)[r] : parseInt(window.getComputedStyle(n)[r]),
                    e = 0 < (e = (a[r] - t) / 10) ? Math.ceil((a[r] - t) / 10) : Math.floor((a[r] - t) / 10);
                t === a[r] ? (clearInterval(o),
                    0 === --i && c && c()) : n.style[r] = "opacity" === r ? (t + e) / 100 : t + e + "px"
            }, 20)
        }(t)
} function ajax(t) {
    if ("[object Object]" !== Object.prototype.toString.call(t)) throw new Error("传递的不是一个对象 请重新传递");
    var e = t.url,
        r = t.method,
        o = t.async,
        n = t.data,
        a = t.headers,
        c = t.datatype,
        i = t.success,
        t = t.error;
    if (!e || "string" != typeof e) throw new Error("你传递的不是一个字符串数据类型");
    if (void 0 !== r && !/^(get|post)$/i.test(r)) throw new Error("你传递的不是get或者是post");
    if (void 0 !== o && "boolean" != typeof o) throw new Error("你传递的不是一个布尔类型的数据");
    if (void 0 !== n && "string" != typeof n && "[object Object]" !== Object.prototype.toString.call(n)) throw new Error("你传递的数据不是字符串也不是对象 必须要传递一个字符串或者对象数据类型");
    if (void 0 !== a && "[object Object]" !== Object.prototype.toString.call(a)) throw new Error("你传递的不是一个对象数据类型 必须要传递一个对象数据类型"); 
    if (void 0 !== c && !/^(string|json)$/i.test(c)) throw new Error("你必须要传递string或者json");
     if (void 0 !== i && "function" != typeof i) throw new Error("你传递的不是一个函数 我需要一个函数");
      if (void 0 !== t && "function" != typeof t) throw new Error("你传递的不是一个函数 我需要一个函数");
       var s, u = { url: e, method: r || "get", async: "boolean" != typeof o || o, data: n || "", headers: _objectSpread({ "content-type": "application/x-www-form-urlencoded" }, a), datatype: c || "string", success: i || function () { }, error: t || function () { } }, f = ("object" === _typeof(n) && (u.data = queryString(n)), /^get$/i.test(u.method) && n && (u.url = u.url + "?" + u.data), new XMLHttpRequest); for (s in f.open(u.method, u.url, u.async), f.onload = function () { var t = f.responseText; if ("json" === u.datatype) try { t = JSON.parse(f.responseText), u.success(t) } catch (t) { u.error(t) } else u.success(t) }, u.headers) f.setRequestHeader(s, u.headers[s]); /^get$/i.test(u.method) ? f.send() : f.send(u.data)
}
function Ajax(t) {
    return new Promise(function (e, r) { ajax({ url: t.url, data: t.data, async: t.async, method: t.method, headers: t.headers, datatype: t.datatype, success: function (t) { e(t) }, error: function (t) { r(t) } }) })
}